/*
 * @Descripttion: 用于生成云认证token的库的头文件
 * @Author: yubo
 * @Date: 2022-08-30 17:28:15
 * @LastEditTime: 2022-08-31 10:10:54
 */
#pragma once

#ifdef _MSC_VER // support microsoft visual c++ only
#ifdef TOKENENCRYPT_EXPORTS
#define TOKENENCRYPT_API __declspec(dllexport)
#else
#define TOKENENCRYPT_API __declspec(dllimport)
#endif
#else
#define TOKENENCRYPT_API
#endif

struct InitParam
{
	char public_key_file[256];
	char err_msg[128];         // hold error message if fail
};

struct TokenParam
{
	char fund_account[128];		
	char account_type;
	int  login_type;
	char time_stamp[15];       // yyyyMMddhhmmss
	char token[2048];           // '\0' terminated
	char err_msg[128];         // hold error message if fail
};

// @return: 0 if succeed, -1 if failed
// thread safe: no
// note: must be called once and only once, before any other functions
extern "C" TOKENENCRYPT_API int token_init(InitParam *init_param);

// @return: 0 if succeed, -1 if failed
// thread safe: yes
extern "C" TOKENENCRYPT_API int token_encrypt(TokenParam *token_param);

//#endif